home *** CD-ROM | disk | FTP | other *** search
/ Utilities Professional 1-1500 / Utilities Professional 1-1500 (1994)(WPD)[!].iso / 12511500 / var1458.dms / var1458.adf / Alerts / Example1.c < prev    next >
C/C++ Source or Header  |  1992-05-01  |  5KB  |  126 lines

  1. /***********************************************************/
  2. /*                                                         */
  3. /* Amiga C Encyclopedia (ACE) V3.0      Amiga C Club (ACC) */
  4. /* -------------------------------      ------------------ */
  5. /*                                                         */
  6. /* Book:    ACM Intuition               Amiga C Club       */
  7. /* Chapter: Alerts                      Tulevagen 22       */
  8. /* File:    Example1.c                  181 41  LIDINGO    */
  9. /* Author:  Anders Bjerin               SWEDEN             */
  10. /* Date:    92-05-01                                       */
  11. /* Version: 1.10                                           */
  12. /*                                                         */
  13. /*   Copyright 1992, Anders Bjerin - Amiga C Club (ACC)    */
  14. /*                                                         */
  15. /* Registered members may use this program freely in their */
  16. /*     own commercial/noncommercial programs/articles.     */
  17. /*                                                         */
  18. /***********************************************************/
  19.  
  20. /* This example displays an Alert message at the top of the display:   */
  21. /*                                                                     */
  22. /*  -----------------------------------------------------------------  */
  23. /*  |                                                               |  */
  24. /*  |  DANGER! Stupid user behind the keyboard!                     |  */
  25. /*  |                                                               |  */
  26. /*  |  Press Left Button to Retry   Press Right Button to Abort     |  */
  27. /*  |                                                               |  */
  28. /*  -----------------------------------------------------------------  */
  29.  
  30.  
  31.  
  32. #include <intuition/intuition.h>
  33.  
  34.  
  35.  
  36. struct IntuitionBase *IntuitionBase;
  37.  
  38.  
  39.  
  40. main()
  41. {
  42.   /* The string which will be printed out: */
  43.   char message[106];
  44.  
  45.   /* In this variable will we store what DisplayAlert() returned: */
  46.   BOOL result;
  47.  
  48.  
  49.  
  50.   /* Before we can use Intuition we need to open the Intuition Library: */
  51.   IntuitionBase = (struct IntuitionBase *)
  52.     OpenLibrary( "intuition.library", 0 );
  53.   
  54.   if( IntuitionBase == NULL )
  55.     exit(); /* Could NOT open the Intuition Library! */
  56.  
  57.  
  58.  
  59.   /* We will now fill the message array with our requirements: */
  60.   
  61.   /* Put the first string into the array. Remember to give space for 3 */
  62.   /* characters in the beginning. We will there store the x (2 bytes)  */
  63.   /* and y (1 byte) position of the text:                              */
  64.  
  65.   strcpy( message, "   DANGER! Stupid user behind the keyboard!");
  66.  
  67.  
  68.   /* Put the second string into the array. Remember to give space for  */
  69.   /* 5 (!) characters/bytes. We will there store the NULL sign which   */
  70.   /* finish of the first string, the TRUE sign which tells Intuition   */
  71.   /* that another string will come, and three bytes used to position   */
  72.   /* the text:                                                         */
  73.  
  74.   strcat( message,
  75.           "     Press Left Button to Retry   Press Right Button to Abort");
  76.     
  77.  
  78.   message[0]=0;       /* X position of the first string */
  79.   message[1]=32;      /*               - " -            */
  80.   message[2]=16;      /* Y             - " -            */
  81.  
  82.   message[43]='\0';   /* NULL sign which finish of the first string. */
  83.   message[44]=TRUE;   /* Continuation byte set to TRUE (new string). */
  84.   
  85.   message[45]=0;      /* X position of the second string. */
  86.   message[46]=32;     /*               - " -              */
  87.   message[47]=32;     /* Y             - " -              */
  88.  
  89.   message[104]='\0';  /* NULL sign which finish of the second string. */
  90.   message[105]=FALSE; /* Continuation byte set to FALSE (last string). */
  91.  
  92.  
  93.  
  94.   /* We will now display the Alert message: */
  95.   result = DisplayAlert( RECOVERY_ALERT, message, 48 );
  96.   
  97.   /*******************************************************************/
  98.   /* RECOVERY_ALERT: The system will survive after this message have */
  99.   /*                 been displayed.                                 */
  100.   /* message:        Pointer to the string which contains the text   */
  101.   /*                 we want to display + information about where we */
  102.   /*                 want to display it (x/y position) etc.          */
  103.   /* 48:             The height of the Alert box. (48 lines high)    */
  104.   /*******************************************************************/
  105.   
  106.   
  107.   
  108.   if(result)
  109.   {
  110.     /* result is equal to TRUE, left button was pressed: */
  111.     printf("RETRY: Left button was pressed\n");
  112.   }
  113.   else
  114.   {
  115.     /* result is equal to FALSE, right button was pressed: */
  116.     printf("ABORT: Right button was pressed\n");
  117.   }
  118.  
  119.  
  120.  
  121.   /* Close the Intuition Library since we have opened it: */
  122.   CloseLibrary( IntuitionBase );
  123.   
  124.   /* THE END */
  125. }
  126.